package fr.nbj.appli;

import java.util.ArrayList;

import android.graphics.Canvas;
import android.graphics.drawable.Drawable;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;

/**
 * Pour le moment, on utilise une liste basique d'items (API Google)
 * @author vinz
 *
 */
public class LandMarkOverlay extends ItemizedOverlay<NbjMapItem> {

	/** @see NbjBar */
	ArrayList<NbjMapItem> items;
	
	
	protected Drawable marker;
	protected Drawable currentBarMark;
	protected Drawable focusBarMark;
	protected OverlayItem gpsItem;
 
	public LandMarkOverlay(Drawable defaultMarker) {
		super(boundCenterBottom(defaultMarker));
		this.marker = defaultMarker;
		this.items = new ArrayList<NbjMapItem>();
		populate();
	}
 
	@Override
	protected NbjMapItem createItem(int index) {
		return (NbjMapItem)items.get(index);
	}
 
	@Override
	public int size() {
		return (items!=null?items.size():0);
 
	}
 
	/*
	 * (non-Javadoc)
	 *
	 * @see
	 * com.google.android.maps.ItemizedOverlay#draw(android.graphics.Canvas,
	 * com.google.android.maps.MapView, boolean)
	 */
	@Override
	public void draw(Canvas canvas, MapView mapView, boolean shadow) {
		populate();
		super.draw(canvas, mapView, false);
		boundCenterBottom(marker);
 
	}
 
	public void addItem(NbjMapItem item) {
		items.add(item);
		
	}
	
	public boolean contains(NbjMapItem item){
		return items.contains(item);
	}
	
	public void markCurrentBar(int idBar){
		if(items != null){
			items.get(idBar).setMarker(currentBarMark);
		}
	}

}
